package 算法图解;

/**
 * @author yzh
 * @date 2021/4/4 12:04
 */
public class _4_1 {
    public static void main(String[] args) {
        int[] nums = new int[]{1, 3, 7, 4};
        System.out.println(new _4_1().count(nums, 0, nums.length - 1));
    }

    public int count(int[] nums, int begin, int end) {
        if (begin >= end) return nums[begin];
        int middle = (begin + end) / 2;
        int left = count(nums, begin, middle);
        int right = count(nums, middle + 1, end);
        return left + right;
    }
}
